Imports System.Drawing.Drawing2D

Public Class frmNewGenericBoundary
    Inherits System.Windows.Forms.Form

    Private m_Cancelled As Boolean = False
    Private ptrBoundary As cmplib01.GenericBoundary

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents cdlFillColor As System.Windows.Forms.ColorDialog
    Friend WithEvents pnlObjectiveProperties As System.Windows.Forms.Panel
    Friend WithEvents lblDeploymentZoneName As System.Windows.Forms.Label
    Friend WithEvents btnOk As System.Windows.Forms.Button
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents txtDescription As System.Windows.Forms.TextBox
    Friend WithEvents txtBoundaryName As System.Windows.Forms.TextBox
    Friend WithEvents btnFillColor As System.Windows.Forms.Button
    Friend WithEvents lblLineStyle As System.Windows.Forms.Label
    Friend WithEvents cboBoundaryStyle As System.Windows.Forms.ComboBox
    Friend WithEvents lblBoundaryWidth As System.Windows.Forms.Label
    Friend WithEvents numBoundaryWidth As System.Windows.Forms.NumericUpDown
    Friend WithEvents lblSetColor As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.cdlFillColor = New System.Windows.Forms.ColorDialog()
        Me.pnlObjectiveProperties = New System.Windows.Forms.Panel()
        Me.numBoundaryWidth = New System.Windows.Forms.NumericUpDown()
        Me.lblBoundaryWidth = New System.Windows.Forms.Label()
        Me.cboBoundaryStyle = New System.Windows.Forms.ComboBox()
        Me.lblLineStyle = New System.Windows.Forms.Label()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.txtDescription = New System.Windows.Forms.TextBox()
        Me.btnFillColor = New System.Windows.Forms.Button()
        Me.lblDeploymentZoneName = New System.Windows.Forms.Label()
        Me.txtBoundaryName = New System.Windows.Forms.TextBox()
        Me.btnOk = New System.Windows.Forms.Button()
        Me.lblSetColor = New System.Windows.Forms.Label()
        Me.pnlObjectiveProperties.SuspendLayout()
        CType(Me.numBoundaryWidth, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'pnlObjectiveProperties
        '
        Me.pnlObjectiveProperties.BackColor = System.Drawing.SystemColors.ControlLight
        Me.pnlObjectiveProperties.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.pnlObjectiveProperties.Controls.AddRange(New System.Windows.Forms.Control() {Me.lblSetColor, Me.numBoundaryWidth, Me.lblBoundaryWidth, Me.cboBoundaryStyle, Me.lblLineStyle, Me.Label1, Me.txtDescription, Me.btnFillColor, Me.lblDeploymentZoneName, Me.txtBoundaryName})
        Me.pnlObjectiveProperties.Location = New System.Drawing.Point(8, 8)
        Me.pnlObjectiveProperties.Name = "pnlObjectiveProperties"
        Me.pnlObjectiveProperties.Size = New System.Drawing.Size(248, 336)
        Me.pnlObjectiveProperties.TabIndex = 24
        '
        'numBoundaryWidth
        '
        Me.numBoundaryWidth.Location = New System.Drawing.Point(8, 144)
        Me.numBoundaryWidth.Name = "numBoundaryWidth"
        Me.numBoundaryWidth.Size = New System.Drawing.Size(80, 20)
        Me.numBoundaryWidth.TabIndex = 32
        '
        'lblBoundaryWidth
        '
        Me.lblBoundaryWidth.Location = New System.Drawing.Point(8, 120)
        Me.lblBoundaryWidth.Name = "lblBoundaryWidth"
        Me.lblBoundaryWidth.Size = New System.Drawing.Size(96, 16)
        Me.lblBoundaryWidth.TabIndex = 31
        Me.lblBoundaryWidth.Text = "Boundary Width"
        '
        'cboBoundaryStyle
        '
        Me.cboBoundaryStyle.Items.AddRange(New Object() {"Solid", "Dot", "Dash"})
        Me.cboBoundaryStyle.Location = New System.Drawing.Point(8, 88)
        Me.cboBoundaryStyle.Name = "cboBoundaryStyle"
        Me.cboBoundaryStyle.Size = New System.Drawing.Size(224, 21)
        Me.cboBoundaryStyle.TabIndex = 30
        Me.cboBoundaryStyle.Text = "Solid Line"
        '
        'lblLineStyle
        '
        Me.lblLineStyle.Location = New System.Drawing.Point(8, 64)
        Me.lblLineStyle.Name = "lblLineStyle"
        Me.lblLineStyle.Size = New System.Drawing.Size(96, 16)
        Me.lblLineStyle.TabIndex = 29
        Me.lblLineStyle.Text = "Boundary Style"
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(8, 176)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(144, 16)
        Me.Label1.TabIndex = 28
        Me.Label1.Text = "Boundary Description"
        '
        'txtDescription
        '
        Me.txtDescription.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.txtDescription.Location = New System.Drawing.Point(8, 200)
        Me.txtDescription.Multiline = True
        Me.txtDescription.Name = "txtDescription"
        Me.txtDescription.Size = New System.Drawing.Size(224, 88)
        Me.txtDescription.TabIndex = 27
        Me.txtDescription.Text = "Unnamed"
        '
        'btnFillColor
        '
        Me.btnFillColor.BackColor = System.Drawing.Color.White
        Me.btnFillColor.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.btnFillColor.Location = New System.Drawing.Point(112, 304)
        Me.btnFillColor.Name = "btnFillColor"
        Me.btnFillColor.Size = New System.Drawing.Size(120, 23)
        Me.btnFillColor.TabIndex = 26
        Me.btnFillColor.Text = "Press To Set Color"
        '
        'lblDeploymentZoneName
        '
        Me.lblDeploymentZoneName.Location = New System.Drawing.Point(8, 8)
        Me.lblDeploymentZoneName.Name = "lblDeploymentZoneName"
        Me.lblDeploymentZoneName.Size = New System.Drawing.Size(96, 16)
        Me.lblDeploymentZoneName.TabIndex = 10
        Me.lblDeploymentZoneName.Text = "Boundary Name"
        '
        'txtBoundaryName
        '
        Me.txtBoundaryName.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.txtBoundaryName.Location = New System.Drawing.Point(8, 32)
        Me.txtBoundaryName.Name = "txtBoundaryName"
        Me.txtBoundaryName.Size = New System.Drawing.Size(224, 20)
        Me.txtBoundaryName.TabIndex = 9
        Me.txtBoundaryName.Text = "Unnamed"
        '
        'btnOk
        '
        Me.btnOk.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.btnOk.Location = New System.Drawing.Point(168, 352)
        Me.btnOk.Name = "btnOk"
        Me.btnOk.TabIndex = 25
        Me.btnOk.Text = "OK"
        '
        'lblSetColor
        '
        Me.lblSetColor.Location = New System.Drawing.Point(48, 307)
        Me.lblSetColor.Name = "lblSetColor"
        Me.lblSetColor.Size = New System.Drawing.Size(56, 16)
        Me.lblSetColor.TabIndex = 33
        Me.lblSetColor.Text = "Set Color"
        '
        'frmNewGenericBoundary
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(266, 384)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.pnlObjectiveProperties, Me.btnOk})
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow
        Me.Name = "frmNewGenericBoundary"
        Me.Text = "Boundary"
        Me.pnlObjectiveProperties.ResumeLayout(False)
        CType(Me.numBoundaryWidth, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region


    Public Sub New(ByRef Boundary As cmplib01.GenericBoundary)
        Me.New()
        ptrBoundary = Boundary
        txtBoundaryName.Text = ptrBoundary.BoundaryName
        txtDescription.Text = ptrBoundary.BoundaryDescription
        numBoundaryWidth.Value = ptrBoundary.BoundaryWidth
        btnFillColor.BackColor = ptrBoundary.BoundaryColor

        Select Case ptrBoundary.BoundaryStyle
            Case DashStyle.Dash : cboBoundaryStyle.Text = "Dash"
            Case DashStyle.Dot : cboBoundaryStyle.Text = "Dot"
            Case DashStyle.Solid : cboBoundaryStyle.Text = "Solid"
        End Select


    End Sub

    Public ReadOnly Property Cancelled() As Boolean
        Get
            Return m_Cancelled
        End Get
    End Property

    Private Sub btnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOk.Click
        SaveProperties()
        Me.Hide()
    End Sub

    Private Sub SaveProperties()
        Try
            ptrBoundary.BoundaryDescription = txtDescription.Text
            ptrBoundary.BoundaryName = txtBoundaryName.Text
            ptrBoundary.BoundaryColor = btnFillColor.BackColor
            ptrBoundary.BoundaryWidth = numBoundaryWidth.Value
            Select Case cboBoundaryStyle.Text
                Case "Solid" : ptrBoundary.BoundaryStyle = DashStyle.Solid
                Case "Dot" : ptrBoundary.BoundaryStyle = DashStyle.Dot
                Case "Dash" : ptrBoundary.BoundaryStyle = DashStyle.Dash
            End Select
        Catch ex As Exception
            HandleException("New Boundary", ex)
            m_Cancelled = True
            Me.Hide()
        End Try
    End Sub

    Private Sub btnFillColor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFillColor.Click
        cdlFillColor.ShowDialog()
        btnFillColor.BackColor = cdlFillColor.Color
    End Sub
End Class
